package com.wss.service.impl;

import com.wss.dao.RegisterDao;
import com.wss.domain.Account;
import com.wss.service.RegisterService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("registerService")
public class RegisterServiceImpl implements RegisterService {

    @Autowired
    private RegisterDao registerDao;

    /**
     * 注册用户
     * @param account
     * @return
     */
    @Override
    public boolean registerAccount(Account account) {
        int res = registerDao.registerAccount(account);
        if (res > 0) {
            return true;
        }else{
            return false;
        }
    }

    /**
     * 检查用户名是否已注册
     * @param username
     * @return
     */
    @Override
    public boolean checkUsername(String username) {
        int res = registerDao.checkUsername(username);
        if (res > 0) {
            return true;
        }else{
            return false;
        }
    }

    /**
     * 获取当前注册的用户
     * @param username
     * @return
     */
    @Override
    public Account getCurrentUser(String username) {
        Account account = registerDao.getCurrentUser(username);
        return account;
    }
}
